import axios from 'axios';

var serverConfig = {
    apiHost: 'http://39.105.164.227:3000'
    // apiHost: 'http://localhost:3001'
}

const AppService = {
    post: (action, params) => {
        return axios.post(`${serverConfig.apiHost}/${action}`, {...params}, 
                        {
                            withCredentials: false,
                            credentials: 'same-origin',
                            headers: {
                            "Content-Type": "application/json",
                            "Access-Control-Allow-Origin" : "*",
                            },
                        }
        );
    },

    get: (action, params) => {
        return axios.get(`${serverConfig.apiHost}/${action}`, 
                        {
                            params: params,
                            withCredentials: false,
                            credentials: 'same-origin',
                            headers: {
                            "Content-Type": "application/json",
                            "Access-Control-Allow-Origin" : "*",
                            },
                        }
        );
    },

    options: (action) => {
        return axios.options(action, {
            withCredentials: false,
            credentials: 'same-origin',
            headers: {
                "Content-Type": "application/json",
                "Access-Control-Allow-Origin" : "*",
            },
        });
    }
}

export default AppService;